import { _decorator, Component, } from 'cc';
import IScene from './IScene';
import { SceneState } from './SceneState';
import ISceneCallback from './ISceneCallback';
export default class AbstractScene extends Component implements IScene {

    protected _sceneName: string;
    protected _sceneState: SceneState;

    protected _enterCallback: ISceneCallback;
    protected _exitCallback: ISceneCallback;

    public constructor(sceneName: string) {
        super();
        this._sceneName = sceneName;
        this.init();
    }

    /**
     * 场景名称
     */
    public get sceneName(): string {
        return this._sceneName;
    }

    public set sceneName(value: string) {
        this._sceneName = value;
    }

    /**
     * 场景状态
     */
    public get state(): SceneState {
        return this._sceneState;
    }

    public set state(value: SceneState) {
        this._sceneState = value;
    }

    /**
     * 场景进入回调
     */
    public get enterCallback(): ISceneCallback {
        return this._enterCallback;
    }

    public set enterCallback(value: ISceneCallback) {
        this._enterCallback = value;
    }

    /**
    * 场景退出回调
    */
    public get exitCallback(): ISceneCallback {
        return this._exitCallback;
    }

    public set exitCallback(value: ISceneCallback) {
        this._exitCallback = value;
    }

    /**
     * 初始化
     */
    protected init(): void {

    }

    /**
     * 进入场景
     */
    public enterScene(): void {

    }

    /**
     * 退出场景
     */
    public exitScene(): void {

    }




    /**
     * 场景进入完成回调，需手动调用
     */
    protected onSceneEntered(): void {
        if (this._enterCallback != null) {
            this._enterCallback(this);
        }
    }

    /**
     * 场景退出完成回调，需手动调用
     */
    protected onSceneExited(): void {
        if (this._exitCallback != null) {
            this._exitCallback(this);
        }
    }
}